<?php
namespace Andorra\dao;

use Andorra\exceptions\AttributeNotFoundException;

class Entity {
	public $entityType = null;
	private $data = null;
	
	public function __construct(EntityType $entityType, $data) {
		$this->entityType = $entityType;
		$this->data = $data;
	}
	
	public function __get($attribute) {			
		if (!in_array($attribute, $this->entityType->columns) &&
				$attribute != $this->entityType->key) {
			throw new AttributeNotFoundException($attribute, $this->entityType);
		}
			
		return $this->data[$attribute];
	}
	
	public function __set($attribute, $value) {
		if (!in_array($attribute, $this->entityType->columns) &&
				$attribute != $this->entityType->key) {
			throw new AttributeNotFoundException($attribute, $this->entityType);
		}
			
		$this->data[$attribute] = $value;
	}
}
?>